package com.xiangxiao.rpan.storage.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @auther xiangxiao
 * @email 573768011@qq.com
 * @data 2023/12/5 15:33
 */
@Component(value = "downloadFileToolManager")
public class DownloadFileToolManager implements DownloadFileTool {
  @Autowired
  @Qualifier(value = "downloadFileToolSelector")
  private DownloadFileToolSelector downloadFileToolSelector;
  @Override
  public void readStreamToFile(String path, HttpServletResponse response) throws IOException {
    downloadFileToolSelector.select().readStreamToFile(path, response);
  }

  @Override
  public String convertMuitlFileToStream(MultipartFile multipartFile, Integer chunkNumber, Integer totalChunks, long blockSize) {
    return downloadFileToolSelector.select().convertMuitlFileToStream(multipartFile, chunkNumber, totalChunks, blockSize);
  }
}
